package com.youyun56.gps.android;

import org.json.JSONObject;

import android.os.Handler;
import android.os.Message;
import android.util.Log;

import com.youyun56.gps.android.commands.CommandType;
import com.youyun56.gps.android.service.LocationUploadService;

public class CarStatusHandler extends Handler {
    private CarStatusActivity activity;
    private final static String tag = CarStatusHandler.class.getName();

    public CarStatusHandler(CarStatusActivity activity) {
        this.activity = activity;
    }

    @Override
    public void handleMessage(Message msg) {
        super.handleMessage(msg);
        try {
            switch (msg.what) {
            case CommandType.Change_Car_Hearvy:
                JSONObject o = (JSONObject) msg.obj;
                LocationUploadService.getInstance().getCar().setCarryStatus(o.getString("hearvy"));
                activity.getBtnHearvy().setEnabled(true);
                activity.changeText();
                break;
            case CommandType.Update_Car_Status_Text:
                activity.changeText();
                break;
            }
        }
        catch (Exception e) {
            Log.e(tag, e.getMessage(), e);
        }

    }

}
